package api

import (
	"encoding/json"
	"github.com/gorilla/mux"
	"net/http"
)

type API struct{}

func (api *API) RegisterRoutes(r *mux.Router) {
	r.HandleFunc("/order", api.PlaceOrder).Methods("POST")
}

func (api *API) PlaceOrder(w http.ResponseWriter, r *http.Request) {
	var req struct {
		UserID int64
		Type   int
		Token  string
		Price  float64
		Amount float64
	}
	json.NewDecoder(r.Body).Decode(&req)
	// 调用撮合引擎下单逻辑
	w.WriteHeader(200)
	w.Write([]byte("下单成功"))
}
